<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>6-匹配26个英文字母</title>
</head>
<body>
    <script>
        //1.匹配小写的26个英文字母
        var reg1 = /^[a-z]$/;
        console.log(reg1.test('a'));//true
        console.log(reg1.test('X'));//false
        console.log(reg1.test('abc'));//false

        console.log('-------------@1-------------');
        //2.匹配小写或大写26个英文字母
        var reg2 = /^[a-zA-Z]$/;
        console.log(reg2.test('Q'));//true
        console.log(reg2.test('u'));//true
        console.log(reg2.test('###'));//false
        console.log('-------------@2-------------');
        //3.匹配小写或大写或_下划线或-中划线
        var reg3 = /^[a-zA-Z_-]$/;
        console.log(reg3.test('a'));//true
        console.log(reg3.test('-'));//true
        console.log(reg3.test('_'));//true
        console.log(reg3.test('Z'));//true
        console.log('-------------@3-------------');
        //4.匹配小写或大写或_下划线或-中划线+数字
        var reg4 = /^[a-zA-Z0-9_-]$/;
        console.log(reg4.test('a'));
        console.log(reg4.test('9'));
        console.log(reg4.test('A'));
        console.log('-------------@4-------------');
        //5.取反,只要不否和正则表达式设置的都是对的
        var reg5 = /^[^a-zA-Z]$/;
        console.log(reg5.test('#'));//true
        console.log(reg5.test('a'));//false
        console.log(reg5.test('@'));//true
    </script>
</body>
</html>